﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace __Able.Network
{
    public class User
    {
        /// <summary>
        /// 
        /// </summary>
        public uint ID { get; set; }
        /// <summary>
        /// 
        /// </summary>
        private byte[] sessionKey;
        /// <summary>
        /// 会话密钥
        /// </summary>
        /// <value></value>
        public byte[] SessionKey
        {
            get { return this.sessionKey; }
        }
        /// <summary>
        /// MD5处理的用户密码
        /// </summary>
        /// <value></value>
        public byte[] PasswordKey { get; private set; }
        /// <summary>
        /// 本地IP
        /// </summary>
        /// <value></value>
        public byte[] IP { get; set; }
        /// <summary>
        /// 上一次登陆IP
        /// </summary>
        /// <value></value>
        public byte[] LastLoginIp { get; set; }
        /// <summary>
        /// 本地端口
        /// </summary>
        /// <value></value>
        public int Port { get; set; }
        /// <summary>
        /// 服务器IP
        /// </summary>
        /// <value></value>
        public byte[] ServerIp { get; set; }
        /// <summary>
        /// 服务器端口
        /// </summary>
        /// <value></value>
        public int ServerPort { get; set; }
        /// <summary>
        /// 上一次登陆时间
        /// </summary>
        /// <value></value>
        public long LastLoginTime { get; set; }
        /// <summary>
        /// 本次登陆时间
        /// </summary>
        /// <value></value>
        public long LoginTime { get; set; }
        /// <summary>
        /// 当前登陆状态，为true表示已经登陆
        /// </summary>
        /// <value></value>
        public bool IsLoggedIn { get; set; }
        /// <summary>
        /// 设置登陆服务器的方式是UDP还是TCP
        /// </summary>
        /// <value></value>
        public bool IsUdp { get; set; }
        /// <summary>
        /// 客户端key
        /// </summary>
        /// <value></value>
        public byte[] ClientKey { get; set; }
        /// <summary>
        /// 初始密钥
        /// </summary>
        /// <value></value>
        public byte[] InitKey { get; private set; }
        /// <summary>
        /// 登录令牌
        /// </summary>
        /// <value></value>
        public byte[] LoginToken { get; set; }
        /// <summary>
        /// 认证令牌
        /// </summary>
        /// <value></value>
        public byte[] AuthToken { get; set; }
        /// <summary>
        ///  请求登录令牌时的随机密钥
        /// </summary>
        /// <value>The login token random key.</value>
        public byte[] LoginTokenRandomKey { get; set; }
        /// <summary>
        /// 临时令牌
        /// </summary>
        /// <value>The temp token.</value>
        public byte[] TempToken { get; set; }
        /// <summary>
        /// 推荐服务器地址
        /// </summary>
        /// <value>The suggest server ip.</value>
        public byte[] SuggestServerIp { get; set; }
        /// <summary>
        /// 被MD5从处理过一次的密码
        /// </summary>
        /// <value>The password MD5.</value>
        public byte[] PasswordMd5 { get; private set; }

        public ushort GetVerifySuffix()
        {
            return (ushort)(new Random()).Next();
        }
        public int GetRandomInt()
        {
            return (new Random()).Next();
        }
        public byte GetRandomByte()
        {
            return (byte)(new Random()).Next();
        }
    }
}
